import { instantStock, instantStockIndex, stockDaily, stockRank } from '../../api/Stock'

const Stock = {
  actions: {
    stockDaily ({ commit }, stockCode) {
      return new Promise((resolve, reject) => {
        stockDaily(stockCode).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    instantStockIndex ({ commit }, stockCode) {
      return new Promise((resolve, reject) => {
        instantStockIndex(stockCode).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    instantStock ({ commit }, stockCode) {
      return new Promise((resolve, reject) => {
        instantStock(stockCode).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    stockRank ({ commit }, pageIndex) {
      return new Promise((resolve, reject) => {
        stockRank(pageIndex).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}
export default Stock
